<%@ include file = "/js/_of_js.jsp"%>
<%@ include file = "/js/_js_for_select.jsp"%>
<%@ include file = "/js/_js_for_window.jsp"%>
<script>
    function goback()
    {
        window.location.href = "<%= request.getContextPath()%>/moduleinfor/viewframe/column/root.jsp?back=true";
    }

    function bodyLoadJS()
    {
        // 被聚焦的控件
        detailForm.code.focus();
    }

    function addTargets_ORG()
    { 
        openWinForAList("Org2OrgsAList.jsp?ALType=Org2Org&rootOrgCode=null&rootRoleCode=null&selectedNodeType=ORG&isMultSelected=true","newwin");
    }
    
    function addTargets_ROLE()
    { 
        openWinForAList("Role2RolesAList.jsp?ALType=Role2Role&rootOrgCode=null&rootRoleCode=null&selectedNodeType=ROLE&isMultSelected=true","newwin");
    }

    function addTargets_POST()
    { 
        openWinForAList("Org2PostsAList.jsp?ALType=Org2Post&rootOrgCode=null&rootRoleCode=null&selectedNodeType=POST&isMultSelected=true","newwin");
    }

    function delTargets()
    {
        this.sycnSelected(detailForm.tIds,detailForm.tTypes);
        this.delSelectedOption(detailForm.tIds);
        this.delSelectedOption(detailForm.tTypes);
    }

    function delAllTargets()
    {
        this.delAllOptions(detailForm.tIds);
        this.delAllOptions(detailForm.tTypes);
    }

    function checkIdAndType(Id,Type)
    {

        if(detailForm.tIds.options.length != detailForm.tTypes.options.length)
        {
               alert("Ids长度" + detailForm.tIds.options.length + "与Types长度" + detailForm.tTypes.options.length + "不一致");
               return false;
        }
        for(var i = 0; i < detailForm.tIds.options.length; i ++)
        {
            if( detailForm.tIds.options[i].value == Id
             && detailForm.tTypes.options[i].value == Type)
            {
                return true;
            }
        }
        return false;
    }

    function getTTypeCode(typeName)
    {
        switch(typeName)
        {
            case "ORG" : return "<%= SysFrameParams.ORG%>";
            case "ROLE" : return "<%= SysFrameParams.ROLE%>";
            case "POST" : return "<%= SysFrameParams.POST%>";
        }
    }

    function setValue(itemIds,itemNames,itemTypes)
    {
        for(var i = 0; i < itemIds.length; i ++)
        {
            if(!this.checkIdAndType(itemIds[i],this.getTTypeCode(itemTypes[i])))
            {
                this.addOption(detailForm.tIds,itemIds[i],itemNames[i] + " (" + itemTypes[i] + ")");
                this.addOption(detailForm.tTypes,this.getTTypeCode(itemTypes[i]),this.getTTypeCode(itemTypes[i]));
            }
        }
    }

    function chooseLogo()
    {
        this.openWinForLogo("<%= request.getContextPath()%>/logo/logoList.jsp?a=a","logoListWin");        
    }

    function setLogo(logoFileName)
    {
        detailForm.imageUrl.value = logoFileName;
        document.imgPreView.src = "<%= request.getContextPath()%>/logo/images/" + logoFileName;

    }

    function selectHome(homeId)
    {
        loadFrame1.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadAreas.jsp?homeId=" + homeId;
    }

    function selectArea(areaId)
    {
        loadFrame2.location.href="<%= request.getContextPath()%>/moduleinfor/viewframe/column/_loadColumns.jsp?areaId=" + areaId;
    }
</script>
<form name="detailForm" action="Controller.jsp" method="post">
    <tr >
        <td class="detailTD11">主页 <font class="xinhao">*</font> </td>
        <td class="detailTD12"colspan="3">
            <select onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true" name = "homeId" onchange="selectHome(this.value)">
            </select>
         &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("homeId")%></font>
        </td>       
           
    </tr>
    <tr >
        <td class="detailTD21">分区 <font class="xinhao">*</font> </td>
        <td class="detailTD22"colspan="3">
            <select onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true" name = "areaId" onchange="selectArea(this.value)">
            </select>
         &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("areaId")%></font>
        </td>       
           
    </tr>
    <tr >
        <td class="detailTD11">父栏目 <font class="xinhao">*</font> </td>
        <td class="detailTD12"colspan="3">
            <select onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true" name= "parentId"  >
            </select>
         &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("parentId")%></font>
        </td>       
    </tr>
    <tr >
        <td class="detailTD21">代码&nbsp;&nbsp;</td>
        <td class="detailTD22" >
            <input type="text" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"  name="code"   maxlength="20" >
        &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("code")%></font>
        </td>
    </tr>
    <tr >
        <td class="detailTD11">名称 <font class="xinhao">*</font> </td>
        <td class="detailTD12" >
            <input type="text" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"  name="name"   maxlength="20" >
            &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("name")%></font>
        </td>
    </tr>
    <tr >
        <td class="detailTD21">图标&nbsp;&nbsp;</td>
        <td class="detailTD22">
            <input type="text" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"  name="imageUrl"   maxlength="50"   >&nbsp;&nbsp;<img width="20" height="20" name="imgPreView" onclick="chooseLogo()" style="cursor:hand">
            &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("imageUrl")%></font>
        </td>       
    </tr>
    <tr >
        <td class="detailTD11">url &nbsp;&nbsp; </td>
        <td class="detailTD12">
            <input type="text" onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true"  name="url"  size="46" maxlength="100" >
            &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("url")%></font>
        </td>       
    </tr>    
    <tr >
        <td class="detailTD21">授权情况&nbsp;&nbsp;</td>
        <td class="detailTD22"colspan="3">
        <table width="50%">
        <tr>
        	<td>
                <select onkeyup="nextOfFocused(this)" afterFocusedJS="" of="true" name="tIds" size="13" multiple style="width=2.7in;"></select>
                <select  name="tTypes" size="8" multiple style="width=2.7in;display:none"></select>
            </td>
        	<td>
                <table>
                    <tr>
                        <td><input type="button"  value="添加机构" onclick = "addTargets_ORG()" ></td>
                    </tr>
                    <tr>
                        <td><input type="button"  value="添加角色" onclick = "addTargets_ROLE()" ></td>
                    </tr>
                    <tr>
                        <td><input type="button"  value="添加岗位" onclick = "addTargets_POST()" ></td>
                    </tr>
                    <tr>
                        <td><input type="button"  value="删    除" onclick = "delTargets()" ></td>
                    </tr>
                    <tr>
                        <td><input type="button"  value="全    删" onclick = "delAllTargets()" ></td>
                    </tr>
                </table>
            </td>
        </tr>
        </table><font color="red"><%= vr.getErrMess("tIds")%></font>   
       </td>       
    </tr>
    <tr >
        <td class="detailTD11">备注&nbsp;&nbsp;</td>
        <td class="detailTD12"colspan="3">
            <textarea  name="remark" rows="3" style="width:2.7in" maxlength="500" ><%= remark%></textarea>
        &nbsp;&nbsp;<font color="red"><%= vr.getErrMess("remark")%></font>    
        </td>       
    </tr>
    <input type="hidden" name="id">
    <input type="hidden" name="serviceURL">
</form>
<textarea style="display:none" name="tempRemark"><%= remark%></textarea>
<iframe name="loadFrame1" src="#" style="display:none" ></iframe>
<iframe name="loadFrame2" src="#" style="display:none" ></iframe>
<iframe name="loadFrame3" src="#" style="display:none" ></iframe>
